package com.pig.config.watcher;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.StringReader;
import java.util.Properties;

/**
 * @author by 李志伟
 * Create Date: 2019/5/30 3:35
 * Description:
 */
public class PersonProcessor implements IParse<Person> {
    private static Logger logger = LoggerFactory.getLogger(PersonProcessor.class);
    private transient Person person = new Person();

    @Override
    public void parseContent(String content) {
        Properties properties = new Properties();
        try {
            properties.load(new StringReader(content));
        } catch (IOException e) {
            logger.error("读取配置文件出错", e);
        }
        person.setName(properties.getProperty("name", "list"));
        person.setAge(Integer.parseInt(properties.getProperty("age", "10")));
    }

    @Override
    public Person get() {
        return person;
    }
}
